from django.db import models

from apps.aiauth.models import Users
from apps.occupation.models import QuestionType


class Medals(models.Model):
    medal_id = models.BigAutoField(db_column='medal_Id', primary_key=True)
    medaltype = models.ForeignKey('Medaltypes', models.DO_NOTHING, db_column='medalType_Id', blank=True, null=True)
    medalname = models.CharField(db_column='medalName', unique=True, max_length=100, blank=True, null=True)
    gentime = models.DateTimeField(db_column='GenTime', blank=True, null=True)

    class Meta:
        db_table = 'medals'
        verbose_name_plural = '用户勋章表'


class Medaltypes(models.Model):
    medaltype_id = models.BigAutoField(db_column='medalType_Id', primary_key=True)
    medaltypename = models.CharField(db_column='medalTypeName', unique=True, max_length=100, blank=True, null=True)
    gentime = models.DateTimeField(db_column='GenTime', blank=True, null=True)

    class Meta:
        db_table = 'medaltypes'
        verbose_name_plural = '勋章类型表'


class Proresult(models.Model):
    proresult_id = models.AutoField(db_column='ProResult_Id', primary_key=True)
    user = models.ForeignKey(Users, models.DO_NOTHING, db_column='User_Id',
                             blank=True, null=True,
                             related_name='user_proresult')
    questiontype = models.ForeignKey(QuestionType, models.DO_NOTHING,
                                     db_column='questionType_Id',
                                     blank=True, null=True, related_name='questiontype_proresult')
    resultstrength = models.CharField(db_column='ResultStrength', max_length=10000)
    resultweakness = models.CharField(db_column='ResultWeakness', max_length=10000)
    resultadvice = models.CharField(db_column='ResultAdvice', max_length=1000)
    countScore = models.CharField(db_column='countScore', max_length=500, blank=True, null=True)
    gentime = models.DateTimeField(db_column='GenTime')

    class Meta:
        db_table = 'proresult'
        verbose_name_plural = '职业素养结果分析表'


class Usermedal(models.Model):
    usermedal_id = models.BigAutoField(db_column='usermedal_Id', primary_key=True)
    user = models.ForeignKey(Users, models.DO_NOTHING,
                             db_column='user_Id',
                             blank=True, null=True,
                             related_name='user_medal')
    medal = models.ForeignKey(Medals, models.DO_NOTHING, db_column='medal_Id', blank=True, null=True)
    context = models.CharField(max_length=100, blank=True, null=True)
    gentime = models.DateTimeField(db_column='GenTime', blank=True, null=True)

    class Meta:
        db_table = 'usermedal'
        unique_together = (('user', 'medal'),)
        verbose_name_plural = '用户勋章映射表'
